package com.cskaoyan.order.controller.hxj;

import com.cskaoyan.mall.commons.constant.SysRetCodeConstants;
import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.order.dto.DeleteOrderRequest;
import com.cskaoyan.order.dto.DeleteOrderResponse;
import com.cskaoyan.order.service.OrderCoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Tiger
 * @since 2022/06/18 14:18
 */


@RestController
public class OrderDeleteController {

    @Autowired
    OrderCoreService orderCoreService;

    @DeleteMapping("/shopping/order/{orderId}")
    public ResponseData deleteOrder(@PathVariable("orderId")String orderId){
        DeleteOrderRequest request = new DeleteOrderRequest();
        request.setOrderId(orderId);
        DeleteOrderResponse response = orderCoreService.deleteOrder(request);
        if(SysRetCodeConstants.SUCCESS.getCode().equals(response.getCode())){
            return new ResponseUtil().setData(response);
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
